package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class Copy here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Copy
{
  private String serialNumber;
  private String purchaseDate;
  private String purchasePrice;
  private boolean isRented;
  private Loan loan;
  
  
  
  
  public Copy(String serialNumber, String purchaseDate, String purchasePrice)//constructor of a copy
  {
      this.purchasePrice=purchasePrice;
      this.purchaseDate=purchaseDate;
      this.serialNumber=serialNumber;
      isRented=false;
    }
    
    
    
    
    
    public void setSerialNumber(String serialNumber)
    {
        this.serialNumber=serialNumber;
    }
    
    
    public void setPurchaseDate(String purchaseDate)
    {
        this.purchaseDate=purchaseDate;
    }
    
   
    public void setPurchasePrice(String purchasePrice)
    {
        this.purchasePrice=purchasePrice;
    }
    
    
    public String getSerialNumber()
    {
        return serialNumber;
    }
    
    
     public String getPurchaseDate()
     {
         return purchaseDate;
        }
        
        
      public String getPurchasePrice()
      {
          return purchasePrice;
        }
  
    public void update( String purchaceDate, String purchasePrice) //changes the copy's purchase price and purhcasedate
    {
      setPurchaseDate(purchaseDate);
      setPurchasePrice(purchasePrice);
  
    }
    
    
    public String toString() //returns a string with all the data in a copy
    {
        
        String s="Serial Number=" + getSerialNumber()+'\n'+ "Purchase Price=" +getPurchasePrice()+'\n';
        s+="Purchase Date" + getPurchaseDate() + '\n' + "State: " +isRentedx() + '\n';
        return s;
        
    }
    
    
    public String isRentedx() // returns a string with state of the dvd... if it's rented or not
    { String s="";
        if(isRented)
        {
            s="Is rented by " + getLoan().getPerson().getName() + '\n';
        }
        else
        {
            s="Is not rented" + '\n';
        }
        return s;
    }
    
    public void rentCopy()
    {
        isRented=true;
    }
    
    
    public void unrentCopy()
    {
        isRented=false;
    }
    
    
    public boolean isRented() 
    {
        return isRented;
    }
    
    
    public void  setLoan(Loan loan)
     {
         this.loan=loan;
        }
        
     public Loan getLoan()
     {
         return loan;
        }
        
     public void deleteLoan()
     {
         loan=null;
        }
    
    
    
    
    
  
        
  
}
